if (!jsx3.lang.Class.forName("ux.cdb.admin.loan.loanWizard.StudenChoiceContent")) {
/**
 * Define the <code>name of class</code> class.
 * This class inherit from <code>jsx3.gui.Block<code> GUI class.
 */
jsx3.Class.defineClass(
    "ux.cdb.admin.loan.loanWizard.StudenChoiceContent",
    jsx3.gui.Block,
    null,
    function (studenContent) {
      /**
       * This method will be called after UI file has deserialized.
       */
      
      studenContent.prototype.homedir = 'ux/cdb/admin/loan/loanWizard/';
      studenContent.prototype.bind = function(fn, scope) {
        scope = scope || this;
        return function() {
          fn.apply(scope, arguments)
        }
      };

      studenContent.prototype.onAfterDeserialize = function() {
        var me = this;
        this.defaultPageSize = 30;
        this.currentPage = 1;
        this.pageControlInit = false;
        this.init();
        this.matrix = this.get("mtxMain");
        this.wizard = this.getAncestorOfType("ux.cdb.admin.loan.loanWizard.LoanBuilder");
        this.pageCtrler = this.get("blkPageWheel");
        this.blkField_applyDateSelect = this.get('blkField_applyDate').getChild(1);
        this.blkField_studentName = this.get('blkField_studentName').getChild(1);
        this.blkField_studentCertId = this.get('blkField_studentId').getChild(1);
        this.blkField_schoolName = this.get('blkField_schoolName').getChild(1);               
                               								
        this.get("btnRefresh").OnRefresh = this.bind(me.refreshData, me);
        
        /*var StudanBaseInfo = this.getDescendantOfName('StudanBaseInfo').getContentPane();
        ux.megatron.Main.loadUIResourceAsync(StudanBaseInfo, "ux.cdb.admin", "ux/cdb/admin/customer/ui/det_baseinfo.xml", me, me.onDetailLoaded);

        var PersonalAccount = this.getDescendantOfName('PersonalAccount').getContentPane();
        ux.megatron.Main.loadUIResourceAsync(PersonalAccount, "ux.cdb.admin", "ux/cdb/admin/customer/ui/det_accinfo.xml", me, me.onDetailLoaded);
        
        var tabStudyInfo = this.getDescendantOfName('tabStudyInfo').getContentPane();
        ux.megatron.Main.loadUIResourceAsync(tabStudyInfo, "ux.cdb.admin", "ux/cdb/admin/customer/ui/det_studyinfo.xml", me, me.onDetailLoaded);
        
        var tabEmployInfo = this.getDescendantOfName('tabEmployInfo').getContentPane();
        ux.megatron.Main.loadUIResourceAsync(tabEmployInfo, "ux.cdb.admin", "ux/cdb/admin/customer/ui/det_careerinfo.xml", me, me.onDetailLoaded);     
      	*/
      	//this.loadApplyDate();
      	//setTimeout(function() {me.loadApplyDate();}, 0);
      }
      
      studenContent.prototype.refreshData = function() {
      	//this.loadMatrixData();//to be delete      	
      	this.currentPage = 1;
      	var params = [null, null, null, null, 1, 30];   
      	// to be done to add params
      	this.searchStudentData(params);        
      }
      
      studenContent.prototype.searchStudentData = function(params) {
      	if(params){
      		var me = this;
      		ux.megatron.util.Dwr.callDwr("AcceptRetailStudentLoanAppUCC", "getStudentListByCondition", params, 
               me, me.onSearchCallback, "AcceptRetailStudentLoanAppUCC");       
      	}
      }
      
      studenContent.prototype.onSearch = function(){
      	var params = [];
      	var studentName = this.blkField_studentName.getValue();
        var applyDate = this.blkField_applyDateSelect.getValue();
        var studentCertId = this.blkField_studentCertId.getValue();
        var schoolName = this.blkField_schoolName.getValue();
        
        //jsx3.log('studentName0:' + studentName);
        studentName = this.emptyToNull(studentName);
        studentCertId = this.emptyToNull(studentCertId);
        schoolName = this.emptyToNull(schoolName);
        
        var ps = ux.megatron.Main.getServer().getDynamicProperty("@cdb@LoanManage@MainPage@PleaseSelect");
        if(applyDate == "ps11"){
        	applyDate = null;
        }
        
/* @JSC :: begin DEBUG */
        jsx3.log('studentName:' + studentName);
        jsx3.log('applyDate:' + applyDate);
        jsx3.log('studentCertId:' + studentCertId);
/* @JSC :: end */
        
        params.push(studentName);
        params.push(studentCertId);
        params.push(schoolName);
        params.push(applyDate);
        params.push(this.currentPage);
        params.push(this.defaultPageSize);
        
        this.searchStudentData(params);
      }
      
      studenContent.prototype.emptyToNull = function(sValue) {
      	var result = null;
      	if(sValue != null && sValue.trim().length > 0){
      		result = sValue;
      	}
      	return result;
      }
      
      studenContent.prototype.onSearchCallback = function(redata) {
        if(!redata) jsx3.log("call load student failed......");

        var flag = redata.res.flag;
        if(flag != 1){
        	var msg = redata.res.msg;
        	jsx3.log("call load student failed: "+msg);
        	return;
        }
        
        var reList = redata.content.data;
        var cdfDoc = ux.megatron.util.Dwr.toCdfDocument(reList,"jsxroot",{"studentId": "jsxid"});
				this.matrix.setSourceXML(cdfDoc);
				this.matrix.repaint();
          
        var resultCount = redata.content.page.count;
        this.resultCount = resultCount;
				this.totalPages = (resultCount%this.defaultPageSize>0)?(parseInt(resultCount/this.defaultPageSize)+1):(resultCount/this.defaultPageSize);
				if(this.totalPages == 0)this.totalPages = 1;
				this.loadPageControler();                                  
      }
      
      studenContent.prototype.loadPageControler = function() {
				if(!this.pageControlInit){
					this.pageCtrler.initialize();
					this.pageControlInit = true;
				}
				this.pageCtrler.setValue(this.currentPage,this.totalPages,this.defaultPageSize,this.resultCount);
				var me = this;
				this.pageCtrler.bindWithMatrix(me,me.onPageChange,me.matrix);
      }
      
      studenContent.prototype.onPageChange = function(msg) {
      	this.currentPage = msg.currentPageNumber;
				var params = [];   
				var studentName = this.blkField_studentName.getValue();
        var applyDate = this.blkField_applyDateSelect.getValue();
        var studentCertId = this.blkField_studentCertId.getValue();
        var schoolName = this.blkField_schoolName.getValue();
        
        studentName = this.emptyToNull(studentName);
        studentCertId = this.emptyToNull(studentCertId);
        schoolName = this.emptyToNull(schoolName);
        if(applyDate == "-1"){
        	applyDate = null;
        }
        
        params.push(studentName);
        params.push(studentCertId);
        params.push(schoolName);
        params.push(applyDate);
        params.push(this.currentPage);
        params.push(this.defaultPageSize);
      	this.searchStudentData(params);     
      }
      
      studenContent.prototype.init = function() {
        this.get("tabbedpane").hide();
        this.get("blkTipInfo").show();
      }
      
      studenContent.prototype._onMatrixSelect = function(selfobj) {
        //this.get("tabbedpane").show();
        //this.get("blkTipInfo").hide();
        var records = selfobj.getSelectedNodes();
        if(records.size()>1){
        	return;
        }
        var record = records.get(0);
        var studentId = record.getAttribute("jsxid");
        var studentName = record.getAttribute("chnFullName");
        var certId = record.getAttribute("certId");
        var schoolId = record.getAttribute("schoolId");
        var schoolName = record.getAttribute("schoolName");
        this.wizard.studentId = studentId;
        this.wizard.studentName = studentName;
        this.wizard.studentCertId = certId;
        this.wizard.schoolId = schoolId;
        this.wizard.schoolName = schoolName;
        this.wizard.individualStatusCode = record.getAttribute("individualStatusCode");;
        //this.loadDetails(studentId);
/* @JSC :: begin DEBUG */
        jsx3.log("studentChoice step1 studentId:"+studentId);      	
/* @JSC :: end */
      }
      
      studenContent.prototype.loadMatrixData = function() {
        ux.megatron.Main.loadResource(this.homedir + "xml/Studen.xml", "ux.cdb.admin", "studen_0610", "xml");
        this.matrix.repaint();
        this.init();
      }
      
      studenContent.prototype.onAfterPaint = function() {
      	this.loadApplyDate();
      }
      
      studenContent.prototype.loadApplyDate = function() {
      	var ps = ux.megatron.Main.getServer().getDynamicProperty("@cdb@LoanManage@MainPage@PleaseSelect");				
				var cdf = jsx3.xml.CDF.Document.newDocument();
				cdf.insertRecord({jsxid: "ps11", jsxtext: ps});
                        var currentYear = (new Date()).getFullYear(), id, text;
                        var unit = ux.megatron.Main.getServer().getDynamicProperty("@cdb@LoanManage@LearnYear");
                        for(var i=-1; i<=9; i++) {
                            id = (currentYear+i) + "" + (currentYear+i+1);
                            text = (currentYear+i) + "-" + (currentYear+i+1) + unit;
                            cdf.insertRecord({jsxid: id, jsxtext: text});
                        };
                        this.get("blkField_applyDate").get("selValue").setSourceXML(cdf);
/* @JSC :: begin DEBUG */
                        jsx3.log("loadApplyDate ps: "+ ps);  
/* @JSC :: end */
                        this.get("blkField_applyDate").get("selValue").setValue("ps11");
                        this.get('blkField_applyDate').getChild(1).repaint();
      }
      
      studenContent.prototype.onDetailLoaded = function(){
      }
      
      studenContent.prototype.loadDetails = function(studentId){
        var me = this;
        var details = this.getDescendantOfName('contentPane').getDescendantsOfType(ux.cdb.admin.dataautomate.GenericDetail);
				for(var i=0;i<details.length;i++){
					details[i].setDataEntityType(ux.cdb.admin.dataautomate.GenericDetail.Student);
					details[i].setDataEntityId(studentId);
					details[i].refreshData();
				}
        /*var StudanBaseInfo = this.getDescendantOfName('StudanBaseInfo').getContentPane();
        if (!StudanBaseInfo.getFirstChild()) {
          ux.megatron.Main.loadUIResourceAsync(StudanBaseInfo, "ux.cdb.admin", "ux/cdb/admin/customer/ui/det_baseinfo.xml", me, me.onDetailLoaded);
        }
        var PersonalAccount = this.getDescendantOfName('PersonalAccount').getContentPane();
        if (!PersonalAccount.getFirstChild()) {
          ux.megatron.Main.loadUIResourceAsync(PersonalAccount, "ux.cdb.admin", "ux/cdb/admin/customer/ui/det_accinfo.xml", me, me.onDetailLoaded);
        }
        
        var tabStudyInfo = this.getDescendantOfName('tabStudyInfo').getContentPane();
        if (!tabStudyInfo.getFirstChild()) {
          ux.megatron.Main.loadUIResourceAsync(tabStudyInfo, "ux.cdb.admin", "ux/cdb/admin/customer/ui/det_studyinfo.xml", me, me.onDetailLoaded);
        }
        
        var tabEmployInfo = this.getDescendantOfName('tabEmployInfo').getContentPane();
        if (!tabEmployInfo.getFirstChild()) {
          ux.megatron.Main.loadUIResourceAsync(tabEmployInfo, "ux.cdb.admin", "ux/cdb/admin/customer/ui/det_careerinfo.xml", me, me.onDetailLoaded);
        }*/
      }
    }
  );
}